<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function Vue({ data }) {
        this._data = data;
        // 为了更加方便的操作实例上的_data中的数据,我们可以把数据遍历在实例上放一份,但是其实操作实例上的数据,其实就是操作_data中对应的数据
        for (let key in this._data) {
          Object.defineProperty(this, key, {
            get: function ProxyGetter() {
              return this._data[key];
            },
            set: function ProxySetter(value) {
              this._data[key] = value;
            },
          });
        }
      }

      const vm = new Vue({
        data: {
          name: "x",
          age: 11,
          gender: "female",
        },
      });

      console.log("vm", vm);
    </script>
  </body>
</html>
